﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using DnnMvcBridge;

namespace DotNetNuke.Modules.SampleMvcModule
{
	public abstract class SampleMvcModuleBase : MvcModuleApplication
	{

		protected override void OnInit(EventArgs e)
		{
			
		}
		
		protected override void MapModuleRoutes(RouteCollection routes)
		{
			const string routeName = "SampleMvcModule_Default";

			if (routes[routeName] == null)
			{

				routes.MapRoute(
					name: routeName,
					url: string.Format("DesktopModules/{0}/{{controller}}/{{action}}/{{id}}", FolderPath),
					defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
					namespaces: new string[] { "DotNetNuke.Modules.SampleMvcModule.Controllers" }
				); 
			}
		}

		private readonly string[] _controllerNamespaces = new[] { "DotNetNuke.Modules.SampleMvcModule.Controllers" };
		protected override string[] ControllerNamespaces
		{
			get { return _controllerNamespaces; }

		}

		protected override string FolderPath
		{
			get { return "SampleMvcModule"; }
		}
	}
}